{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
        <input type="hidden" name="id" value="{$info.id}" />
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="title" lay-verify="required" value="{$info['title']}" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转出钱包</label>
            <div class="layui-input-inline layui-input-wrap">
                <select name="from" lay-filter="aihao">
                    {foreach $wallet_arr as $wallet_type=>$wallet_name}
                        <option {if $info && $wallet_type==$info['from']}selected{/if} value="{$wallet_type}">{$wallet_name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转入钱包</label>
            <div class="layui-input-inline layui-input-wrap">
                <select name="to" lay-filter="aihao">
                    {foreach $wallet_arr as $wallet_type=>$wallet_name}
                        <option {if $info && $wallet_type==$info['from']}selected{/if} value="{$wallet_type}">{$wallet_name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转账类型</label>
            <div class="layui-input-block">
                <input type="radio" name="tome"  {if $info && $info['tome']==0}checked='checked'{/if} value="0" title="转给他人">
                <input type="radio" name="tome"  {if $info && $info['tome']==1}checked='checked'{/if} value="1" title="转给自己">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手续费(%)</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="fee" lay-verify="required" value="{$info['fee']}" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid"></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手续费来源</label>
            <div class="layui-input-block">
                <input type="radio" name="fee_type"  {if $info && $info['fee_type']==0}checked='checked'{/if} value="0" title="额外货币">
                <input type="radio" name="fee_type"  {if $info && $info['fee_type']==1}checked='checked'{/if} value="1" title="转出金额">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转换比例</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="changebl" lay-verify="required" value="{$info['changebl']}" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid">例：设置0.8表示转出1到账0.8，不设置或设置0代表1：1转换</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转账最大金额</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="max" lay-verify="required" value="{$info['max']}" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转账最小金额</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="min" lay-verify="required" value="{$info['min']}" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status"  {if $info && $info['status']==0}checked='checked'{/if} value="0" title="关闭">
                <input type="radio" name="status"  {if $info && $info['status']==1}checked='checked'{/if} value="1" title="开启">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确认</button>
            </div>
        </div>
    </form>
    </div>
</div>
<script>
    layui.use(function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });
        // 提交事件
        form.on('submit(demo1)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('save')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('提交成功');
                    }else{
                        layer.msg(res.msg);
                    }
                    setTimeout(function(){
                        parent.layer.closeAll();
                        parent.tableIns.reload()
                    },1000)
                }
            });
            return false; // 阻止默认 form 跳转
        });

        // 日期
        laydate.render({
            elem: '#date'
        });


    });
</script>
</body>
</html>